<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/** Trainings models **/
class Policiess extends CI_Model {
    
    private $policies   = 'policies';
    private $users      = 'employee';
    
    function getAllFileRecords($type='')
	{
		$sql = "SELECT * 
                FROM ".$this->policies;
		if($type)
			$sql .= " WHERE policies_type='".$type."'";
        $Q=$this->db->query($sql);        
		return $Q->result_array();
	}
	
	function saveFile($file=''){
		$value =  array( 'policies_title'  	=>  $this->input->post('title'),
						 'policies_date'  	=>  date('Y-m-d H:i:s'),
						 'policies_name'	=>	$file,	
						 'policies_type'    =>	$this->input->post('category'),
						 'policies_content' =>	$this->input->post('content'),
						 'EmployeeID'		=>	$this->session->userdata('user_login'));
		$this->db->insert($this->policies,$value);				 
	}
    
	function removeFile($id){
		$this->db->where('policies_id',TRIM($id));				 
		$this->db->delete($this->policies);				 
	}
    
}    